{{define "index"}}
{{template "top" .}}

<div class="row row-cols-1 row-cols-md-2">
  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Authorized Health Authorities</h5>
      </div>

      {{if .apps}}
        <div class="list-group list-group-flush">
          {{range .apps}}
            <a href="/app?apn={{.AppPackageName}}" class="list-group-item list-group-item-action">
              <code>{{.AppPackageName}}</code>
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no authorized health authorities.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/app?apn=" class="btn btn-primary">New Authorized Health Authority</a>
      </div>
    </div>
  </div>

  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Verification Keys</h5>
      </div>

      {{if .healthauthorities}}
        <div class="list-group list-group-flush">
          {{range .healthauthorities}}
            <a href="/healthauthority/{{.ID}}" class="list-group-item list-group-item-action">
              {{.Name}} (<code>{{.Issuer}}</code>)
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no health authorities configured.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/healthauthority/0" class="btn btn-primary">New Verification Key</a>
      </div>
    </div>
  </div>

  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Export Configurations</h5>
      </div>

      {{if .exports}}
        <div class="list-group list-group-flush">
          {{range .exports}}
            <a href="/exports/{{.ConfigID}}" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{.OutputRegion}}</h5>
                <small>ID: {{.ConfigID}}</small>
              </div>
              <p class="mb-1">
                Bucket: {{.BucketName}}
              </p>
              {{with $t := .From | htmlDatetime}}
                <small class="d-block">Begins: {{$t}}</small>
              {{end}}
              {{with $t := .Thru | htmlDatetime}}
                <small class="d-block">Expires: {{$t}}</small>
              {{end}}
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no export configurations.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/exports/0" class="btn btn-primary">Create new Export Config</a>
      </div>
    </div>
  </div>

  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Signature Infos</h5>
      </div>

      {{if .siginfos}}
        <div class="list-group list-group-flush">
          {{range .siginfos}}
            <a href="/siginfo/{{.ID}}" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{.SigningKeyID}}</h5>
                <small>ID: {{.ID}}</small>
              </div>
              <p class="mb-1">
                SigningKey: {{.SigningKey}}<br />
                Version: {{.SigningKeyVersion}}
              </p>
              {{with $t := .FormattedEndTimestamp}}
                <small class="d-block">Expires: {{$t}}</small>
              {{end}}
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no signature info configurations.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/siginfo/0" class="btn btn-primary">Create new Signature Info</a>
      </div>
    </div>
  </div>

  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Export Importer Configurations</h5>
      </div>

      {{if .exportImporters}}
        <div class="list-group list-group-flush">
          {{range .exportImporters}}
            <a href="/export-importers/{{.ID}}" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{.Region}}</h5>
                <small>ID: {{.ID}}</small>
              </div>
              <p class="mb-0">
                Root: {{.ExportRoot}}
              </p>
              <p class="mb-1">
                Index: {{.IndexFile}}
              </p>
              {{with $t := .From | htmlDatetime}}
                <small class="d-block">Begins: {{$t}}</small>
              {{end}}
              {{with $t := .Thru | htmlDatetime}}
                <small class="d-block">Expires: {{$t}}</small>
              {{end}}
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no export importer configurations.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/export-importers/0" class="btn btn-primary">Create new Export Importer Config</a>
      </div>
    </div>
  </div>

  <div class="col mb-4">
    <div class="card">
      <div class="card-header">
        <h5 class="mb-0">Mirrors</h5>
      </div>

      {{if .mirrors}}
        <div class="list-group list-group-flush">
          {{range .mirrors}}
            <a href="/mirrors/{{.ID}}" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{.CloudStorageBucket}}</h5>
                <small>ID: {{.ID}}</small>
              </div>
              <p class="mb-0">
                Filename Root: {{.FilenameRoot}}
              </p>
              <p class="mb-0">
                Export Root: {{.ExportRoot}}
              </p>
              <p class="mb-1">
                Index File: {{.IndexFile}}
              </p>
            </a>
          {{end}}
        </div>
      {{else}}
        <div class="card-body">
          <p class="text-center mb-0"><em>There are no mirrors.</em></p>
        </div>
      {{end}}

      <div class="card-body d-grid">
        <a href="/mirrors/0" class="btn btn-primary">Create new Mirror</a>
      </div>
    </div>
  </div>
</div>

{{template "bottom" .}}
{{end}}
